//图片上传预览    IE是用了滤镜。
// preview
function previewImage(file)
    {
        var MAXWIDTH  = 260; 
        var MAXHEIGHT = 180;
        var div = document.getElementById('preview');
        if (file.files && file.files[0])
        {
            div.innerHTML ='<img id=imghead>';
            var img = document.getElementById('imghead');
            img.onload = function(){
                var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
                img.width  =  rect.width;
                img.height =  rect.height;
                // img.style.marginLeft = rect.left+'px';
                //img.style.marginTop = rect.top+'px';
            }
                var reader = new FileReader();
                reader.onload = function(evt){
                	img.src = evt.target.result;
                 upLoadImg(evt.target.result,8,1);
                }
                reader.readAsDataURL(file.files[0]);
            }
        else //兼容IE
        {
            var sFilter='filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="';
            file.select();
            var src = document.selection.createRange().text;
            div.innerHTML = '<img id=imghead>';
            var img = document.getElementById('imghead');
            img.filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = src;
            var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
            status =('rect:'+rect.top+','+rect.left+','+rect.width+','+rect.height);
            div.innerHTML = "<div id=divhead style='width:"+rect.width+"px;height:"+rect.height+"px;margin-top:"+rect.top+"px;"+sFilter+src+"\"'></div>";
        }
    }
    
    
      /**
         * 
         * @param {Object} image  图片名字
         * @param {Object} type   图片类型
         * @param {Object} index  图片序号
         */
        function upLoadImg(image,type,index){
        	
        	var base64 ="";
				$.ajax({
					url: urlcore + "/api/attachment/saveFile",
					type: "post",
					dataType: 'json',
					contentType: "application/json;charset=utf-8",
					data: JSON.stringify({
						"base64":image
					}),
					processData: false,
					success: function(data) {
						if(data.success == true) {
							var da=data.data;
							
							if(type==1){
						    document.getElementById("fengmian").value="";
							document.getElementById("fengmian").value=da;
							}else if(type==2){
							document.getElementById("fengmian3").value="";
							document.getElementById("fengmian3").value=da;
							}else if(type==3){
							document.getElementById("fengmian4").value="";
							document.getElementById("fengmian4").value=da;
							}else if(type==4){
							document.getElementById("fengmian5").value="";
							document.getElementById("fengmian5").value=da;	
							}else if(type==5){
							document.getElementById("fengmian6").value="";
							document.getElementById("fengmian6").value=da;	
							}else if(type==8){
						    document.getElementById("touxiang").value="";
							document.getElementById("touxiang").value=da;
							alert(da)
							}
							
							
							/*
						var da = data.data;
						if(type==1){
					      if(index==1){
					      	document.getElementById("product_url1").value=da;
					      }else if(index==2){
					      	document.getElementById("product_url2").value=da;
					      }else if(index==3){
				      		document.getElementById("product_url3").value=da;
					      }
					
						}else if(type==2){
					      if(index==1){
					      	document.getElementById("house_url1").value=da;
					      }else if(index==2){
					      	document.getElementById("house_url2").value=da;
					      }else if(index==3){
					      	document.getElementById("house_url3").value=da;
					      }
					
						}
					*/}else{
						alert(data.msg)
					}
					},
					error: function() {
						/*alert("error");*/
					}
				});
        }
        
    
      /**
         * 
         * @param {Object} image  图片名字
         * @param {Object} type   图片类型
         * @param {Object} index  图片序号
         */
        function upLoadImg2(image,type,index){
       
        	var base64 ="";
				$.ajax({
					url: urlcore + "/api/attachment/saveFile",
					type: "post",
					dataType: 'json',
					contentType: "application/json;charset=utf-8",
					data: JSON.stringify({
						"base64":image
					}),
					processData: false,
					success: function(data) {
						if(data.success == true) {
							var da=data.data;
							
			                 $("#xijietu").each(function(){
			                 	if ($(this).val()==""){
			                 	
								     $(this).val(da);
							}
			                 });
							
					
							/*
						var da = data.data;
						if(type==1){
					      if(index==1){
					      	document.getElementById("product_url1").value=da;
					      }else if(index==2){
					      	document.getElementById("product_url2").value=da;
					      }else if(index==3){
				      		document.getElementById("product_url3").value=da;
					      }
					
						}else if(type==2){
					      if(index==1){
					      	document.getElementById("house_url1").value=da;
					      }else if(index==2){
					      	document.getElementById("house_url2").value=da;
					      }else if(index==3){
					      	document.getElementById("house_url3").value=da;
					      }
					
						}
					*/}else{
						alert(data.msg)
					}
					},
					error: function() {
						/*alert("error");*/
					}
				});
        }
        
        function upLoadImg3(image,type,index){
        	var base64 ="";
				$.ajax({
					url: urlcore + "/api/attachment/saveFile",
					type: "post",
					dataType: 'json',
					contentType: "application/json;charset=utf-8",
					data: JSON.stringify({
						"base64":image
					}),
					processData: false,
					success: function(data) {
						if(data.success == true) {
							var da=data.data;
							//alert(JSON.stringify(da));
			                 $("#jubaobao").each(function(){
			                 	if ($(this).val()==""){
								     $(this).val(da);
							}
			                 });
							
					
							/*
						var da = data.data;
						if(type==1){
					      if(index==1){
					      	document.getElementById("product_url1").value=da;
					      }else if(index==2){
					      	document.getElementById("product_url2").value=da;
					      }else if(index==3){
				      		document.getElementById("product_url3").value=da;
					      }
					
						}else if(type==2){
					      if(index==1){
					      	document.getElementById("house_url1").value=da;
					      }else if(index==2){
					      	document.getElementById("house_url2").value=da;
					      }else if(index==3){
					      	document.getElementById("house_url3").value=da;
					      }
					
						}
					*/}else{
						alert(data.msg)
					}
					},
					error: function() {
						/*alert("error");*/
					}
				});
        }
    
    
     function upLoadImg4(image,index){
        	var base64 ="";
				$.ajax({
					url: urlcore + "/api/attachment/saveFile",
					type: "post",
					dataType: 'json',
					contentType: "application/json;charset=utf-8",
					data: JSON.stringify({
						"base64":image
					}),
					processData: false,
					success: function(data) {
						if(data.success == true) {
							var da=data.data;
					$('#pingluntupian'+index+'').append('<li><img src="'+da+'"><input type="text" style="display: none;" class="xijietu'+index+'" id="xijietu" value="'+da+'"></li>');	
					}else{
						alert(data.msg)
					}
					},
					error: function() {
						/*alert("error");*/
					}
				});
        }
    
    
    function clacImgZoomParam( maxWidth, maxHeight, width, height ){
        var param = {top:0, left:0, width:width, height:height};
        if( width>maxWidth || height>maxHeight )
            {
                rateWidth = width / maxWidth;
                rateHeight = height / maxHeight;
                
                if( rateWidth > rateHeight )
                {
                    param.width =  maxWidth;
                    param.height = Math.round(height / rateWidth);
                }else
                {
                    param.width = Math.round(width / rateHeight);
                    param.height = maxHeight;
                }
            }
            param.left = Math.round((maxWidth - param.width) / 2);
            param.top = Math.round((maxHeight - param.height) / 2);
            return param;
        }
// preview1
function previewImage1(file)
{
          var MAXWIDTH  = 260; 
          var MAXHEIGHT = 180;
          var div = document.getElementById('preview1');
          
          if (file.files && file.files[0])
          {
          
              div.innerHTML ='<img id=imghead1>';
            
              var img = document.getElementById('imghead1');
           
              img.onload = function(){
                var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
                img.width  =  rect.width;
                img.height =  rect.height;
                // img.style.marginLeft = rect.left+'px';
                //img.style.marginTop = rect.top+'px';
              }
              var reader = new FileReader();
              reader.onload = function(evt){
              	img.src = evt.target.result;
              upLoadImg(evt.target.result,1,2);
              }
              reader.readAsDataURL(file.files[0]);
            
          }
          else //兼容IE
          {
            var sFilter='filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="';
            file.select();
            var src = document.selection.createRange().text;
            div.innerHTML = '<img id=imghead1>';
            var img = document.getElementById('imghead1');
            img.filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = src;
            var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
            status =('rect:'+rect.top+','+rect.left+','+rect.width+','+rect.height);
            div.innerHTML = "<div id=divhead style='width:"+rect.width+"px;height:"+rect.height+"px;margin-top:"+rect.top+"px;"+sFilter+src+"\"'></div>";
          }
        }
        
        
        
        function clacImgZoomParam( maxWidth, maxHeight, width, height ){
            var param = {top:0, left:0, width:width, height:height};
            if( width>maxWidth || height>maxHeight )
            {
                rateWidth = width / maxWidth;
                rateHeight = height / maxHeight;
                
                if( rateWidth > rateHeight )
                {
                    param.width =  maxWidth;
                    param.height = Math.round(height / rateWidth);
                }else
                {
                    param.width = Math.round(width / rateHeight);
                    param.height = maxHeight;
                }
            }
            
            param.left = Math.round((maxWidth - param.width) / 2);
            param.top = Math.round((maxHeight - param.height) / 2);
            return param;
        }
// preview2
function previewImage2(file)
        {
        	
          var MAXWIDTH  = 260; 
          var MAXHEIGHT = 180;
          var div =this.document.getElementById('preview22');
          if (file.files && file.files[0])
          {
              div.innerHTML ='<img id="imghead22">';
              var img =this.document.getElementById('imghead22');
              img.onload = function(){
                var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
                img.width  =  rect.width;
                img.height =  rect.height;
                // img.style.marginLeft = rect.left+'px';
                //img.style.marginTop = rect.top+'px';
              }
              var reader = new FileReader();
              reader.onload = function(evt){img.src = evt.target.result;
           
               upLoadImg2(evt.target.result,1,2);
              }
              reader.readAsDataURL(file.files[0]);
          }
          else //兼容IE
          {
            var sFilter='filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="';
            file.select();
            var src = document.selection.createRange().text;
            div.innerHTML = '<img id=imghead22>';
            var img = document.getElementById('imghead22');
            img.filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = src;
            var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
            status =('rect:'+rect.top+','+rect.left+','+rect.width+','+rect.height);
            div.innerHTML = "<div id=divhead style='width:"+rect.width+"px;height:"+rect.height+"px;margin-top:"+rect.top+"px;"+sFilter+src+"\"'></div>";
          }
        }
        
        function clacImgZoomParam( maxWidth, maxHeight, width, height ){
            var param = {top:0, left:0, width:width, height:height};
            if( width>maxWidth || height>maxHeight )
            {
                rateWidth = width / maxWidth;
                rateHeight = height / maxHeight;
                
                if( rateWidth > rateHeight )
                {
                    param.width =  maxWidth;
                    param.height = Math.round(height / rateWidth);
                }else
                {
                    param.width = Math.round(width / rateHeight);
                    param.height = maxHeight;
                }
            }
            
            param.left = Math.round((maxWidth - param.width) / 2);
            param.top = Math.round((maxHeight - param.height) / 2);
            return param;
        }
// preview3
function previewImage3(file)
        {
          var MAXWIDTH  = 260; 
          var MAXHEIGHT = 180;
          var div = document.getElementById('preview3');
          if (file.files && file.files[0])
          {
              div.innerHTML ='<img id=imghead3>';
              var img = document.getElementById('imghead3');
              img.onload = function(){
                var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
                img.width  =  rect.width;
                img.height =  rect.height;
                // img.style.marginLeft = rect.left+'px';
                //img.style.marginTop = rect.top+'px';
              }
              var reader = new FileReader();
              reader.onload = function(evt){
              	img.src = evt.target.result;
              upLoadImg(evt.target.result,2,2);
              }
              reader.readAsDataURL(file.files[0]);
          }
          else //兼容IE
          {
            var sFilter='filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="';
            file.select();
            var src = document.selection.createRange().text;
            div.innerHTML = '<img id=imghead3>';
            var img = document.getElementById('imghead3');
            img.filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = src;
            var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
            status =('rect:'+rect.top+','+rect.left+','+rect.width+','+rect.height);
            div.innerHTML = "<div id=divhead style='width:"+rect.width+"px;height:"+rect.height+"px;margin-top:"+rect.top+"px;"+sFilter+src+"\"'></div>";
          }
        }
        
        function clacImgZoomParam( maxWidth, maxHeight, width, height ){
            var param = {top:0, left:0, width:width, height:height};
            if( width>maxWidth || height>maxHeight )
            {
                rateWidth = width / maxWidth;
                rateHeight = height / maxHeight;
                
                if( rateWidth > rateHeight )
                {
                    param.width =  maxWidth;
                    param.height = Math.round(height / rateWidth);
                }else
                {
                    param.width = Math.round(width / rateHeight);
                    param.height = maxHeight;
                }
            }
            
            param.left = Math.round((maxWidth - param.width) / 2);
            param.top = Math.round((maxHeight - param.height) / 2);
            return param;
        }   
// preview4
function previewImage4(file)
        {
          var MAXWIDTH  = 260; 
          var MAXHEIGHT = 180;
          var div = document.getElementById('preview4');
          if (file.files && file.files[0])
          {
              div.innerHTML ='<img id=imghead4>';
              var img = document.getElementById('imghead4');
              img.onload = function(){
                var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
                img.width  =  rect.width;
                img.height =  rect.height;
                // img.style.marginLeft = rect.left+'px';
                //img.style.marginTop = rect.top+'px';
              }
              var reader = new FileReader();
              reader.onload = function(evt){
              	img.src = evt.target.result;
                upLoadImg(evt.target.result,3,2);
              }
              reader.readAsDataURL(file.files[0]);
          }
          else //兼容IE
          {
            var sFilter='filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="';
            file.select();
            var src = document.selection.createRange().text;
            div.innerHTML = '<img id=imghead4>';
            var img = document.getElementById('imghead4');
            img.filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = src;
            var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
            status =('rect:'+rect.top+','+rect.left+','+rect.width+','+rect.height);
            div.innerHTML = "<div id=divhead style='width:"+rect.width+"px;height:"+rect.height+"px;margin-top:"+rect.top+"px;"+sFilter+src+"\"'></div>";
          }
        }
        function clacImgZoomParam( maxWidth, maxHeight, width, height ){
            var param = {top:0, left:0, width:width, height:height};
            if( width>maxWidth || height>maxHeight )
            {
                rateWidth = width / maxWidth;
                rateHeight = height / maxHeight;
                
                if( rateWidth > rateHeight )
                {
                    param.width =  maxWidth;
                    param.height = Math.round(height / rateWidth);
                }else
                {
                    param.width = Math.round(width / rateHeight);
                    param.height = maxHeight;
                }
            }
            
            param.left = Math.round((maxWidth - param.width) / 2);
            param.top = Math.round((maxHeight - param.height) / 2);
            return param;
        } 
// preview5
function previewImage5(file)
        {
          var MAXWIDTH  = 260; 
          var MAXHEIGHT = 180;
          var div = document.getElementById('preview5');
          if (file.files && file.files[0])
          {
              div.innerHTML ='<img id=imghead5>';
              var img = document.getElementById('imghead5');
              img.onload = function(){
                var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
                img.width  =  rect.width;
                img.height =  rect.height;
                // img.style.marginLeft = rect.left+'px';
                //img.style.marginTop = rect.top+'px';
              }
              var reader = new FileReader();
              reader.onload = function(evt){img.src = evt.target.result;upLoadImg(evt.target.result,4,2);}
              reader.readAsDataURL(file.files[0]);
          }
          else //兼容IE
          {
            var sFilter='filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="';
            file.select();
            var src = document.selection.createRange().text;
            div.innerHTML = '<img id=imghead5>';
            var img = document.getElementById('imghead5');
            img.filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = src;
            var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
            status =('rect:'+rect.top+','+rect.left+','+rect.width+','+rect.height);
            div.innerHTML = "<div id=divhead style='width:"+rect.width+"px;height:"+rect.height+"px;margin-top:"+rect.top+"px;"+sFilter+src+"\"'></div>";
          }
        }
        function clacImgZoomParam( maxWidth, maxHeight, width, height ){
            var param = {top:0, left:0, width:width, height:height};
            if( width>maxWidth || height>maxHeight )
            {
                rateWidth = width / maxWidth;
                rateHeight = height / maxHeight;
                
                if( rateWidth > rateHeight )
                {
                    param.width =  maxWidth;
                    param.height = Math.round(height / rateWidth);
                }else
                {
                    param.width = Math.round(width / rateHeight);
                    param.height = maxHeight;
                }
            }
            
            param.left = Math.round((maxWidth - param.width) / 2);
            param.top = Math.round((maxHeight - param.height) / 2);
            return param;
        } 
// preview6
function previewImage6(file)
        {
          var MAXWIDTH  = 260; 
          var MAXHEIGHT = 180;
          var div = document.getElementById('preview6');
          if (file.files && file.files[0])
          {
              div.innerHTML ='<img id=imghead6>';
              var img = document.getElementById('imghead6');
              img.onload = function(){
                var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
                img.width  =  rect.width;
                img.height =  rect.height;
                // img.style.marginLeft = rect.left+'px';
                //img.style.marginTop = rect.top+'px';
              }
              var reader = new FileReader();
              reader.onload = function(evt){img.src = evt.target.result;upLoadImg(evt.target.result,5,2);
              }
              reader.readAsDataURL(file.files[0]);
          }
          else //兼容IE
          {
            var sFilter='filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="';
            file.select();
            var src = document.selection.createRange().text;
            div.innerHTML = '<img id=imghead6>';
            var img = document.getElementById('imghead6');
            img.filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = src;
            var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
            status =('rect:'+rect.top+','+rect.left+','+rect.width+','+rect.height);
            div.innerHTML = "<div id=divhead style='width:"+rect.width+"px;height:"+rect.height+"px;margin-top:"+rect.top+"px;"+sFilter+src+"\"'></div>";
          }
        }
        function clacImgZoomParam( maxWidth, maxHeight, width, height ){
            var param = {top:0, left:0, width:width, height:height};
            if( width>maxWidth || height>maxHeight )
            {
                rateWidth = width / maxWidth;
                rateHeight = height / maxHeight;
                
                if( rateWidth > rateHeight )
                {
                    param.width =  maxWidth;
                    param.height = Math.round(height / rateWidth);
                }else
                {
                    param.width = Math.round(width / rateHeight);
                    param.height = maxHeight;
                }
            }
            
            param.left = Math.round((maxWidth - param.width) / 2);
            param.top = Math.round((maxHeight - param.height) / 2);
            return param;
        } 
// preview7
function previewImage7(file)
        {
          var MAXWIDTH  = 260; 
          var MAXHEIGHT = 180;
          var div = document.getElementById('preview7');
          if (file.files && file.files[0])
          {
              div.innerHTML ='<img id=imghead7>';
              var img = document.getElementById('imghead7');
              img.onload = function(){
                var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
                img.width  =  rect.width;
                img.height =  rect.height;
                // img.style.marginLeft = rect.left+'px';
                //img.style.marginTop = rect.top+'px';
              }
              var reader = new FileReader();
              reader.onload = function(evt){img.src = evt.target.result;}
              reader.readAsDataURL(file.files[0]);
          }
          else //兼容IE
          {
            var sFilter='filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="';
            file.select();
            var src = document.selection.createRange().text;
            div.innerHTML = '<img id=imghead7>';
            var img = document.getElementById('imghead7');
            img.filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = src;
            var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
            status =('rect:'+rect.top+','+rect.left+','+rect.width+','+rect.height);
            div.innerHTML = "<div id=divhead style='width:"+rect.width+"px;height:"+rect.height+"px;margin-top:"+rect.top+"px;"+sFilter+src+"\"'></div>";
          }
        }
        function clacImgZoomParam( maxWidth, maxHeight, width, height ){
            var param = {top:0, left:0, width:width, height:height};
            if( width>maxWidth || height>maxHeight )
            {
                rateWidth = width / maxWidth;
                rateHeight = height / maxHeight;
                
                if( rateWidth > rateHeight )
                {
                    param.width =  maxWidth;
                    param.height = Math.round(height / rateWidth);
                }else
                {
                    param.width = Math.round(width / rateHeight);
                    param.height = maxHeight;
                }
            }
            
            param.left = Math.round((maxWidth - param.width) / 2);
            param.top = Math.round((maxHeight - param.height) / 2);
            return param;
        } 
        







// preview2
function ngpreviewImage(file)
        {
          var MAXWIDTH  = 260; 
          var MAXHEIGHT = 180;
          var div =this.document.getElementById('ngpreview');
          if (file.files && file.files[0])
          {
              div.innerHTML ='<img id="ngimghead">';
              var img =this.document.getElementById('ngimghead');
              img.onload = function(){
                var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
                img.width  =  rect.width;
                img.height =  rect.height;
                // img.style.marginLeft = rect.left+'px';
                //img.style.marginTop = rect.top+'px';
              }
              var reader = new FileReader();
              reader.onload = function(evt){img.src = evt.target.result;
              
               upLoadImg3(evt.target.result,1,2);
              }
              reader.readAsDataURL(file.files[0]);
          }
          else //兼容IE
          {
            var sFilter='filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="';
            file.select();
            var src = document.selection.createRange().text;
            div.innerHTML = '<img id=imghead2>';
            var img = document.getElementById('imghead2');
            img.filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = src;
            var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
            status =('rect:'+rect.top+','+rect.left+','+rect.width+','+rect.height);
            div.innerHTML = "<div id=divhead style='width:"+rect.width+"px;height:"+rect.height+"px;margin-top:"+rect.top+"px;"+sFilter+src+"\"'></div>";
          }
        }
        




function previewImagenew(file)
    {
        	
          var MAXWIDTH  = 260; 
          var MAXHEIGHT = 180;
          var div =this.document.getElementById('preview22');
          if (file.files && file.files[0])
          {
              div.innerHTML ='<img id="imghead22">';
              var img =this.document.getElementById('imghead22');
              img.onload = function(){
                var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
                img.width  =  rect.width;
                img.height =  rect.height;
                // img.style.marginLeft = rect.left+'px';
                //img.style.marginTop = rect.top+'px';
              }
              var reader = new FileReader();
              reader.onload = function(evt){img.src = evt.target.result;
                
               upLoadImg4(evt.target.result,$(file).attr("id"));
              }
              reader.readAsDataURL(file.files[0]);
          }
          else //兼容IE
          {
            var sFilter='filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="';
            file.select();
            var src = document.selection.createRange().text;
            div.innerHTML = '<img id=imghead22>';
            var img = document.getElementById('imghead22');
            img.filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = src;
            var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
            status =('rect:'+rect.top+','+rect.left+','+rect.width+','+rect.height);
            div.innerHTML = "<div id=divhead style='width:"+rect.width+"px;height:"+rect.height+"px;margin-top:"+rect.top+"px;"+sFilter+src+"\"'></div>";
          }
        }